package com.apes.framework.plugin.workflow.deployment;

import com.apes.framework.jpa.BaseModel;
import com.apes.framework.jpa.DefaultPersistListener;
import com.apes.framework.jpa.Model;
import com.apes.framework.jpa.comment.Comment;
import com.apes.framework.jpa.generator.ApesGenerator;
import lombok.Getter;
import lombok.Setter;
import org.hibernate.annotations.DynamicInsert;
import org.hibernate.annotations.DynamicUpdate;
import org.hibernate.annotations.SelectBeforeUpdate;

import javax.persistence.*;

@Getter
@Setter
@SelectBeforeUpdate
@DynamicInsert
@DynamicUpdate
@Entity
@EntityListeners(DefaultPersistListener.class)
@Table(name = Deployment.CONST_TABLE_NAME, indexes = {@Index(columnList = "md5", unique = true)})
public class Deployment extends BaseModel {
    public static final String CONST_TABLE_NAME = "wf_deployment";

    @Id
    @Column(name = "id", length = 250)
    @ApesGenerator(code = CONST_TABLE_NAME, name = "流程部署")
    private String id;

    @Column(name = "md5", length = 64)
    private String md5;

    @Version
    @Column(name = "version", columnDefinition = "number(10) default 0")
    @Comment("版本号")
    private int version;  //JPA乐观锁
}
